app.controller("brandController",function ($scope, $http, $controller, brandService) {

    $controller("baseController", {$scope:$scope});
    //新增品牌
    $scope.save = function () {
        var object = null;
        if($scope.entity.id != null) {
            object = brandService.update($scope.entity);
        }else {
            object = brandService.add($scope.entity);
        }
        object.success(function (response) {
            if (response.success) {
                alert(response.message);
                $scope.reloadList();
            } else {
                alert(response.message);
            }
        })
    }
    //按id查询品牌
    $scope.getBrand = function (id) {
        brandService.getBrand(id).success(function (respose) {
            $scope.entity = respose;
        });
    }

    //通过id删除品牌
    $scope.delBrand = function () {
        brandService.delBrand($scope.selectIds).success(function (response) {
            if(response.success) {
                alert(response.message);
                $scope.reloadList();
            }else {
                alert(response.message);
            }
        })
    }
    $scope.searchEntity={};
    //分页
    $scope.search = function (pageIndex, pageSize) {
        brandService.search(pageIndex, pageSize, $scope.searchEntity).success(function (respose) {
            $scope.list = respose.rows;
            $scope.paginationConf.totalItems = respose.total;
        });
    }
});